"""
鼠标点击操作
"""
import time
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

url="http://sahitest.com/demo/clicks.htm"
driver = webdriver.Chrome()
driver.maximize_window()
driver.get(url=url)
driver.implicitly_wait(10)
#双击元素
db_el=driver.find_element(By.XPATH,"//input[@value='dbl click me']")
#单击元素
click1=driver.find_element(By.XPATH,"//input[@value='click me']")
#右键右击
right_click=driver.find_element(By.XPATH,"//input[@value='right click me']")
#方块勾选
fk_click=driver.find_element(By.XPATH,"/html/body/form/input[6]")
#单选勾选
dx_click=driver.find_element(By.XPATH,"/html/body/form/input[7]")
#链式写法
# ActionChains(driver).double_click(db_el).click(click1).click(fk_click).click(dx_click).context_click(right_click).perform()
#分布式写法
action=ActionChains(driver)
#双击
action.double_click(db_el)
#单击
action.click(click1)
time.sleep(3)
#勾选方块
action.click(fk_click)
time.sleep(3)
#单选
action.click(dx_click)
time.sleep(3)
#右键点击
action.context_click(right_click).perform()
